home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2010 Summer - Disc 1 / WN_Ete2010_CD1.iso / Onglet5 / Weezo / Weezo setup.exe / {code_appDir} / www / res / blog / selfBlog / upload.php < prev   
PHP Script  |  2010-05-19  |  3KB  |  90 lines

  1. <?php
  2. /**
  3.  * Blog image upload script
  4.  *
  5.  * Display "please wait" screen
  6.  * Upload an image to server, resize it and put it in blog temp directory
  7.  *
  8.  * If no file is sent, display "please wait" screen and call doSendImage script in opener window
  9.  * This script submit file send form, targeting current widows
  10.  * file reception is then detected.
  11.  *
  12.  * PHP version 5
  13.  *
  14.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  15.  * that is available through the world-wide-web at the following URI:
  16.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  17.  * the PHP License and are unable to obtain it through the web, please
  18.  * send a note to license@php.net so we can mail you a copy immediately.
  19.  *
  20.  * @category   NA
  21.  * @package    NA
  22.  * @author     Nicolas Bruley / Peer 2 World <contact@weezo.net>
  23.  * @copyright  2005-2009 Nicolas Bruley / Peer 2 World
  24.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  25.  * @version    CVS: $Id:$
  26.  * @link       http://www.weezo.net
  27.  * @since      File available since Release 1.0.0
  28.  */
  29.  
  30. require_once('uploadWindow.php');
  31.  
  32. function processUploadedFile(){
  33.     global $transfersArray;
  34.     $errorMessage=false;
  35.  
  36.     // Move uploaded file to resource directory
  37.     $uploadDir = cfAppResourceDir();
  38.     $uploadFile = $uploadDir . '/tmp.'.cfFileExtension(basename($_FILES['ulInput']['name']));
  39.     if(!move_uploaded_file($_FILES['ulInput']['tmp_name'], $uploadFile)){
  40.         $fileTransfered=false;
  41.         $errorMessage = cfCaption('genError');
  42.     }
  43.     else $fileTransfered=true;
  44.  
  45.     // Verify that it is an image
  46.     if(!$errorMessage && substr($_FILES['ulInput']['type'],0,5)!='image') {
  47.         $errorMessage=cfCaption('blogErrorNotImage');
  48.         $fileTransfered=false;
  49.         unlink($uploadFile);
  50.     }
  51.  
  52.     // Verify that user has administrator rights
  53.     if(!$errorMessage && !cfUGetVar('administrator')){
  54.         $errorMessage = cfCaption('genError');
  55.         $fileTransfered=false;
  56.         unlink($uploadFile);
  57.     }
  58.  
  59.     // Output size
  60.     $dW=150;$dH=150;
  61.     if(!$errorMessage && isset($_POST['size'])){
  62.         switch ($_POST['size']){
  63.             case 'big':$dW=600;$dH=600;break;
  64.             case 'medium':$dW=300;$dH=300;break;
  65.             case 'small':$dW=150;$dH=150;break;
  66.             default:$dW=150;$dH=150;break;
  67.         }
  68.     }
  69.  
  70.     // Output position
  71.     if(!$errorMessage){
  72.         cfRSetVar('uploadedImagePosition','top');
  73.         if(isset($_POST['position'])){
  74.             switch ($_POST['position']){
  75.                 case 'top':cfRSetVar('uploadedImagePosition','top'); break;
  76.                 case 'bottom':cfRSetVar('uploadedImagePosition','bottom');break;
  77.             }
  78.         }
  79.     }
  80.  
  81.     // Generate jpg image from sent image
  82.     if(!$errorMessage){
  83.         cfCreateResizedJPG($uploadFile, 0, 0, $uploadDir.'/tmpImg.jpg', $dW,$dH); unlink($uploadFile);
  84.         cfRSetVar('uploadedImage',true);
  85.     }
  86.     // Display upload completed page
  87.     if(!$errorMessage) displayUploadCompletedPage($uploadDir.'/tmpImg.jpg',false);
  88.     else displayUploadCompletedPage(false,$errorMessage);
  89. }
  90. ?>